package db

import "go_code/gin-blog/model"

//获取全部留言
func GetAllLeave() ([]*model.Leave, error) {
	leaveList := []*model.Leave{}
	if err := DB.Table("leave").Order("create_time desc").Where("status=1").Find(&leaveList).Error; err != nil {
		return nil, err
	}
	return leaveList, nil
}

//插入留言
func InsertLeave(leave *model.Leave) (bool, error) {
	if err := DB.Table("leave").Create(leave).Error; err != nil {
		return false, err
	}
	return true, nil
}
